import request from '@/utils/request'
import type { attrData, attrResponseData, categoryResponseData } from './model/attr'

// 枚举接口
enum API {
    C1 = '/admin/product/getCategory1',
    C2 = '/admin/product/getCategory2/',
    C3 = '/admin/product/getCategory3/',
    ATTR= '/admin/product/attrInfoList/',
    ADDATTR = '/admin/product/saveAttrInfo',
    DELETEATTR = '/admin/product/deleteAttr/'
}


// 获取一级分类数据的接口
export const reqC1List = ()=>request.get<any,categoryResponseData>(API.C1)

// 获取二级分类数据的接口
export const reqC2List = (category1Id:number|string)=>request.get<any,categoryResponseData>(API.C2 + category1Id)


// 获取二级分类数据的接口
export const reqC3List = (category2Id:number|string)=>request.get<any,categoryResponseData>(API.C3 + category2Id)


// 获取平台属性的接口
export const reqAttrList = (category1Id:number|string,category2Id:number|string,category3Id:number|string)=>request.get<any,attrResponseData>(API.ATTR+`${category1Id}/${category2Id}/${category3Id}`)

// 添加/修改平台属性的接口
export const reqAddAttr = (data:attrData) =>request.post<any,any>(API.ADDATTR,data)


// 删除属性的接口
export const reqDeleteAttr = (id:number|string) =>request.delete<any,any>(API.DELETEATTR+id)